package com.zzy.controller;

import com.zzy.model.AjaxMsg;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping(value = "/index")
public class TestController {

    @RequestMapping()
    public AjaxMsg index(){
        return AjaxMsg.returnAjaxMsg("首页");
    }

    @RequestMapping("/error")
    @ResponseBody
    public AjaxMsg error(){
        return AjaxMsg.returnAjaxMsg("error");
    }


    /**
     * 返回一个json对象
     */
    @RequestMapping({"/test"})
    @ResponseBody
    public AjaxMsg getById(HttpServletRequest request) {

        return AjaxMsg.returnAjaxMsg("调用了provider 的测试 ");
    }

    @GetMapping("get")
    public AjaxMsg get(){
        return AjaxMsg.returnAjaxMsg();
    }
}
